package com.yearEndWorkload.controller;

import com.alibaba.excel.EasyExcel;
import com.yearEndWorkload.common.Result;
import com.yearEndWorkload.pojo.form.add.AddTypeStandardForm;
import com.yearEndWorkload.pojo.form.add.CopyTypeStandardForm;
import com.yearEndWorkload.pojo.form.update.UpdateTypeStandardForm;
import com.yearEndWorkload.pojo.query.TypeStandardQuery;
import com.yearEndWorkload.service.impl.TypeStandardServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/s3/typeStandard")
@Tag(name = "年终工作量类型管理",description = "年终工作量类型管理的管理，涉及到 增删查改，以及每一年的类型的批量复制（每年的年终工作量标准可能不一致）。")
public class TypeStandardController {

    @Autowired
    TypeStandardServiceImpl typeStandardService;

    @Operation(summary = "查找工作量类型情况",description = "查找工作量类型情况")
    @PostMapping("/getList")
    public Result getList(@RequestBody TypeStandardQuery typeStandardQuery) {
        return typeStandardService.getList(typeStandardQuery);
    }

    @Operation(summary = "批量复制某年的年终工作量标准到某年",description = "批量复制某年的年终工作量标准到某年")
    @PostMapping("/copy")
    public Result copy(@RequestBody CopyTypeStandardForm copyTypeStandardForm) {
        return typeStandardService.copy(copyTypeStandardForm);
    }


    @Operation(summary = "添加单个年终工作量类型",description = "查找工作量类型情况")
    @PostMapping("/addOne")
    public Result addOne(@RequestBody AddTypeStandardForm addTypeStandardForm) {
        return typeStandardService.addOne(addTypeStandardForm);
    }

    @Operation(summary = "通过id批量删除",description = "通过id批量删除")
    @DeleteMapping("/deleteByIds")
    public Result deleteByIds(@RequestBody List<Integer> ids) {
        return typeStandardService.deleteByIds(ids);
    }

    @Operation(summary = "通过id修改某一个",description = "通过id修改某一个")
    @PostMapping("/updateById")
    public Result updateById(@RequestBody UpdateTypeStandardForm updateTypeStandardForm) {
        typeStandardService.updateById(updateTypeStandardForm);
        return Result.success("修改成功");
    }

}
